t = int(input())
for _ in range(t):
    A, B, C = map(int, input().split())
    ans = 0
    min_a_c = min(A, C)
    ans += min_a_c * 2
    A -= min_a_c
    C -= min_a_c
    count_B = B >> 1
    ans += count_B * 2
    B -= 2 * count_B

    count_C = C >> 1
    ans += count_C
    C -= 2 * count_C

    print(ans)
